package leetcode.code036;

public class Solution2 extends Solution036 {

	@Override
	public boolean isValidSudoku(char[][] board) {
		int[] row = new int[10], col = new int[10], area = new int[10];
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 9; j++) {
				char c = board[i][j];
				if (c == '.')
					continue;
				int u = c - '0';
				int idx = i / 3 * 3 + j / 3;
				if ((((row[i] >> u) & 1) == 1) || (((col[j] >> u) & 1) == 1) || (((area[idx] >> u) & 1) == 1))
					return false;
				row[i] |= (1 << u);
				col[j] |= (1 << u);
				area[idx] |= (1 << u);
			}
		}
		return true;
	}

	public static void main(String[] args) {
		Solution2 so = new Solution2();
		so.debug1();
		so.debug2();

	}

}
